package Bidostar_Data;

import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;

public class Bidostar_GetCode
{

    public static final Logger logger = Logger.getLogger(Bidostar_GetCode.class.getClass());

    public static String Certified()
    {
        String certified = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Certified);
            rs.next();
            certified = rs.getString("certified");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return certified;
    }

    public static String phone()
    {
        String phone = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.phone);
            rs.next();
            phone = rs.getString("phone");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return phone;
    }

    public static String name()
    {
        String name = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.name);
            rs.next();
            name = rs.getString("name");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return name;
    }

    public static String license_no()
    {
        String license_no = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.license_no);
            rs.next();
            license_no = rs.getString("license_no");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return license_no;
    }

    public static String ACL_id()
    {
        String ACL_id = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.ACL_id);
            rs.next();
            ACL_id = rs.getString("ACL_id");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return ACL_id;
    }

    public static String ACL_Time()
    {
        String ACL_Time = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.ACL_Time);
            rs.next();
            ACL_Time = rs.getString("ACL_Time");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return ACL_Time;
    }

    public static String ACL_id2()
    {
        String ACL_id2 = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.ACL_id2);
            rs.next();
            ACL_id2 = rs.getString("ACL_id");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return ACL_id2;
    }

    public static String Platform_Ci()
    {
        String platform = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Platform_Ci);
            rs.next();
            platform = rs.getString("platform");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return platform;
    }

    public static String Remark()
    {
        String remark = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Remark);
            rs.next();
            remark = rs.getString("remark");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return remark;
    }

    public static String Password_Ci()
    {
        String cu_password = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Password_Ci);
            rs.next();
            cu_password = rs.getString("cu_password");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return cu_password;
    }

    /*
            数据库查询
     */
    public static String name_Ci()
    {
        String cu_name = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.name_Ci);
            rs.next();
            cu_name = rs.getString("cu_name");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return cu_name;
    }

    public static String Device_Code()
    {
        String Device_Code = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Device_Code);
            rs.next();
            Device_Code = rs.getString("device_code");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Device_Code;
    }

    public static String PhoneReport_Imei()
    {
        String PhoneReport_Imei = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.PhoneReport_Imei);
            rs.next();
            PhoneReport_Imei = rs.getString("imei");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return PhoneReport_Imei;
    }


    public static String Admin_Password()
    {
        String Admin_Password = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Admin_Password);
            rs.next();
            Admin_Password = rs.getString("password");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Admin_Password;
    }

    public static String Admin_NickName()
    {
        String Admin_NickName = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Admin_NickName);
            rs.next();
            Admin_NickName = rs.getString("nickName");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Admin_NickName;
    }

    public static String Master_Pw()
    {
        String Master_Pw = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Master_PW);
            rs.next();
            Master_Pw = rs.getString("password");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Master_Pw;
    }

    public static String Ci_Password()
    {
        String Ci_Password = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Ci_Password);
            rs.next();
            Ci_Password = rs.getString("cu_password");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Ci_Password;
    }

    public static String cu_name()
    {
        String cu_name = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.cu_name);
            rs.next();
            cu_name = rs.getString("cu_name");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return cu_name;
    }

    public static String ta_name()
    {
        String ta_name = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.ta_name);
            rs.next();
            ta_name = rs.getString("name");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return ta_name;
    }

    public static String Ta_Password()
    {
        String Ta_Password = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Ta_password);
            rs.next();
            Ta_Password = rs.getString("password");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Ta_Password;
    }

    public static String Dc_Password()
    {
        String Dc_Password = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.Dc_password);
            rs.next();
            Dc_Password = rs.getString("password");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Dc_Password;
    }

    public static String Dc_name()
    {
        String Dc_name = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.dc_name);
            rs.next();
            Dc_name = rs.getString("nickName");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return Dc_name;
    }

    public static String FeedBack_Info()
    {
        String FeedBack_Info = "";
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection(Baseinfo.SqlUrl, Baseinfo.User, Baseinfo.Password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(Baseinfo.FeedBack_Info);
            rs.next();
            FeedBack_Info = rs.getString("content");
        } catch (Exception e)
        {
            logger.info(e);
        }
        return FeedBack_Info;
    }
    //接口获取参数值

    public static String Getresult_Insurance()
    {
        Map<String, String> params = new HashMap<String, String>();
        params.put("account", Baseinfo.Ci_User);
        params.put("password", Bidostar_GetCode.Ci_Password());
        String result = Httpclient_doPost_result.doPost(Baseinfo.Insurance_Login, params, "UTF-8");
        JSONObject jsob_Insurance = JSONObject.parseObject(result);
        return String.valueOf(jsob_Insurance.get("result"));
    }

    public static String Getresult_Traffic()
    {
        Map<String, String> params = new HashMap<String, String>();
        params.put("account", Baseinfo.Ta_User);
        params.put("password", Bidostar_GetCode.Ta_Password());
        String result = Httpclient_doPost_result.doPost(Baseinfo.Traffic_Login, params, "UTF-8");
        JSONObject jsob_Traffic = JSONObject.parseObject(result);
        return String.valueOf(jsob_Traffic.get("result"));
    }

    public static String Getresult_Operatin()
    {
        Map<String, String> params = new HashMap<String, String>();
        params.put("account", Baseinfo.Dc_User);
        params.put("password", Bidostar_GetCode.Dc_Password());
        String result = Httpclient_doPost_result.doPost(Baseinfo.Operation_Login, params, "UTF-8");
        JSONObject jsob_Operation = JSONObject.parseObject(result);
        return String.valueOf(jsob_Operation.get("result"));
    }

    public static void main(String[] args)
    {
//        logger.info(cu_name());
//        logger.info(ta_name());
//        logger.info(Dc_name());
//        logger.info(FeedBack_Info());
//        logger.info(Ci_Password());
//        logger.info(Ta_Password());
//        logger.warn(Dc_Password());
//        logger.info(Certified());
//        logger.info(name());
//        logger.info(phone());
//        logger.info(license_no());
//        logger.info((ACL_id()));
//        logger.info(ACL_Time());
//        logger.info(ACL_id2());
//        logger.info(Platform_Ci());
//        logger.info(Remark());
//        logger.info(Password_Ci());
//        logger.info(name_Ci());
//        logger.info(Device_Code());
//        logger.info(PhoneReport_Imei());
//        logger.info(Admin_Password());
//        logger.info(Admin_NickName());
//        logger.info(Master_Pw());
        logger.info(Getresult_Insurance());
    }
}
